package cn.jinbyte.web.config;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * Cors防护配置
 *
 * @author jinty
 */
@Data
public class CorsProperties {
    /**
     * 是否启用CORS配置
     */
    private boolean enabled = true;

    /**
     * 允许的源
     */
    private List<String> allowedOrigins = new ArrayList<>();

    /**
     * 允许的HTTP方法
     */
    private List<String> allowedMethods = List.of("GET", "POST", "PUT", "DELETE", "OPTIONS");

    /**
     * 允许的请求头
     */
    private List<String> allowedHeaders = List.of("*");

    /**
     * 暴露的响应头
     */
    private List<String> exposedHeaders = new ArrayList<>();

    /**
     * 是否允许携带凭证
     */
    private boolean allowCredentials = true;

    /**
     * 预检请求的缓存时间(秒)
     */
    private long maxAge = 3600;
}
